/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package gui.event.thuoc;

import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import model.dao.thuoc.ThuocDAO;
import org.hibernate.HibernateException;

/**
 *
 * @author nv_ca@live.com
 */
public class ThuocCapNhatFull_evt {

    public static final void btnCloseActionPerformed(JDialog dlg) {
        dlg.dispose();
    }

    public static final void btnSaveActionPerformed(JTextField textField, JSpinner spinner) {
        try {
            int thuocMa = Integer.parseInt(textField.getText());
            int sl = (int) spinner.getValue();
            ThuocDAO.updateSoLuongThuoc(thuocMa, sl);
        } catch (NumberFormatException | HibernateException ex) {
            JOptionPane.showMessageDialog(null, "Mã thuốc sai.");
            return;
        }
        JOptionPane.showMessageDialog(null, "Update số lượng thuốc thành công.");
    }
}
